<?php
/* @var $this BackendController */
/* @var $model Category */

$this->breadcrumbs=array(
    Yii::t('CategoryModule.base','Categories')=>array('index'),
    Yii::t('CategoryModule.base','Manage'),
);
$this->menu=array(
	array('label'=>'<span class="glyphicon glyphicon-list"></span>&nbsp'.Yii::t('CategoryModule.base','List Category'), 'url'=>array('index')),
	array('label'=>'<span class="glyphicon glyphicon-plus"></span>&nbsp'.Yii::t('CategoryModule.base','Create Category'), 'url'=>array('create')),
);
Yii::app()->clientScript->registerPackage('fancybox');
Yii::app()->clientScript->registerScript('search', "
    $('.fancybox').fancybox();
    $('.glyphicon, img').tooltip();
    $('.btn-primary').tooltip({container:'body'});
    $('.search-button').click(function(){
        $('.search-form').toggle();
        return false;
    });
    $('.search-form form').submit(function(){
        $('#category-grid').yiiGridView('update', {
            data: $(this).serialize()
        });
        return false;
    });
    $('#refresh').on('click',function(e){
        $.fn.yiiGridView.update('category-grid');
    });
");
?>
<div class="panel panel-primary">
    <div class="panel-heading">
        <i class="fa fa-cogs"></i><span class="h4"><?php echo Yii::t('CategoryModule.base','Manage Categories')?></span><a id="refresh" class="alignRight white font16" href="#"><i class="fa fa-refresh"></i></a>
    </div>
    <div class="panel-body">
        <div class="search-form">
        <?php $this->renderPartial('_search',array(
            'model'=>$model,
        )); ?>
        </div><!-- search-form -->

        <?php $this->widget('zii.widgets.grid.CGridView', array(
            'id'=>'category-grid',
            'dataProvider'=>$model->search(),
            //'filter'=>$model,
            'pager' => array('cssFile' => Yii::app()->theme->baseUrl . '/assets/gridview/pager.css'),
            'baseScriptUrl'=>Yii::app()->theme->baseUrl.'/assets/gridview',
            'columns'=>array(
                array(
                    'name' => 'id',
                    'type' => 'raw',
                    'value'=>'CHtml::tag("span",array("class"=>"badge"),$data->id)',
                    'htmlOptions' => array('style'=>'width:50px'),
                ),
                array(
                    'name' => 'name',
                    'type' => 'raw',
                    'htmlOptions' => array('style'=>'width:200px'),
                ),
                array(
                    'name'=>'create_time',
                    'type'=>'raw',
                    'value'=>'$data->getCreateDateTimeFormat()',
                    'htmlOptions' => array('style'=>'width:180px'),
                ),
                array(
                    'name'=>'update_time',
                    'type'=>'raw',
                    'value'=>'$data->getUpdateDateTimeFormat()',
                    'htmlOptions' => array('style'=>'width:180px'),
                ),
                array(
                    'name'=>'create_user_id',
                    'type'=>'raw',
                    'value'=>'$data->createUser->name', // =>если пустое значение create_user_id -'CHtml::value($data, "createUser.name");'
                     'htmlOptions' => array('style'=>'width:150px'),
                ),
                array(
                    'name'=>'record_counts',
                    'type'=>'raw',
                    'value'=>'$data->getRecordCount()',
                    'htmlOptions' => array('style'=>'width:100px'),
                ),
                /*
                'update_user_id',
                */
                array(
                    'class'=>'CButtonColumn',
                    'htmlOptions' => array('style'=>'width:50px;font-size:20px'),
                    'template'=>'{view}  {update}  {delete}',
                    'buttons'=>array(
                        'view'=>array(
                            'label'=>'',
                            'imageUrl'=>'',
                            'options'=>array('class'=>'glyphicon glyphicon-eye-open','style'=>'padding-right:5px','data-toggle'=>'tooltip','title'=>Yii::t('MenuModule.base','View')),
                        ),
                        'update'=>array(
                            'label'=>'',
                            'imageUrl'=>'',
                            'options'=>array('class'=>'glyphicon glyphicon-edit','style'=>'padding-right:5px','data-toggle'=>'tooltip','title'=>Yii::t('MenuModule.base','Edit')),
                        ),
                        'delete'=>array(
                            'label'=>'',
                            'imageUrl'=>'',
                            'options'=>array('class'=>'glyphicon glyphicon-trash','style'=>'padding-right:5px','data-toggle'=>'tooltip','title'=>Yii::t('MenuModule.base','Delete')),
                        ),
                    )
                ),
            ),
        )); ?>
        </div>
    <div class="panel-footer">
    </div>
</div>